<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备布局图')" />
    <link th:href="@{/css/eqpbar/eqpchar.css}" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="bigbox">
        <div class="title">
            <span class="title-font">设备即时状态图</span>
        </div>
        <div class="zt1" id="RUN">
            <span class="zt1-font">01-RUN/<br>01-REW</span>
        </div>
        <div class="zt2" id="IDLE">
            <span class="zt2-font">02-IDLE</span>
        </div>
        <div class="zt3" id="NONPROD">
            <span class="zt3-font">03-DOWN/<br>03-REP/<br>03-POST</span>
        </div>
        <div class="zt4" id="SHUTDOWN">
            <span class="zt4-font">04-PM/<br>04-POST</span>
        </div>
        <div class="zt5" id="NONCHDOWN">
            <span class="zt5-font">05-I01/<br>05-I02</span>
        </div>
        <div class="zt6" id="SHUTDOWN">
            <span class="zt6-font">06-SETUP/<br>06-QC</span>
        </div>
        <div class="zt7" id="NONCHDOWN">
            <span class="zt7-font">07-PRUN/<br>07-TUNE</span>
        </div>

        <div class="bigbox2">
            <div class="yibu">
                <span th:each="mesLocationList : ${mesLoEqps.mesLocationList}" >
                    <div class="location" th:text="${mesLocationList.location}"></div>
                    <span th:each="eqp : ${mesLocationList.locationEquipmentsList}">
                        <a href="javascript:void(0);" th:onclick="eqpClick([[(${eqp.equipmentId})]])">
                            <div class="PNS002" th:id="${eqp.equipmentId}" th:text="${eqp.equipmentId}"></div>
                        </a>
                    </span>
                </span>
            </div>
        </div>
    </div>

    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "equipment/eqpchar";
        var json=eval({ color:{
                "01-RUN":"#00FF00", "01-REW":"#00FF00", "02-IDLE":"#FFFF00", "03-DOWN":"#FF0000",
                "03-REP":"#FF0000", "03-POST":"#FF0000", "04-PM":"#376096", "04-POST":"#376096",
                "05-I01":"#953735", "05-I02":"#953735", "06-SetUp":"#FF00FF", "06-QC":"#FF00FF",
                "07-PRUN":"#7030A0", "07-TUNE":"#7030A0"
        }});

        function eqpClick(equipmentId) {
            var url = prefix + "/queryequipdetail?equipmentId=" + equipmentId ;
            $.modal.openTab('设备看板', url);
        }

        // 设置设备状态颜色
        function setEqpState() {
            $.post(prefix + "/getEqpStatus", {}, function(result) {
                if (result.code == web_status.SUCCESS) {
                    var data = result.data;
                    var SQljson = eval( data );
                    $("div").each(function(){
                        for ( var i = 0; i < SQljson.length; i++) {
                            try {
                                document.getElementById(SQljson[i].equipmentId).style.background=json.color[SQljson[i].subState];
                            } catch(e) {}
                        }
                    });
                } else {
                    $.modal.alertError(result.msg);
                }
            });
            setTimeout("setEqpState();",30000);
        }

        $(function() {
            setEqpState();
        });
    </script>
</body>
</html>